﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace CommunityServerRest {
	[XmlRoot("Blog")]
	public class Blog {
		[XmlAttribute("Id")]
		public int Id { get; set; }

		[XmlAttribute("Endpoint")]
		public string Endpoint { get; set; }


		[XmlElement("Name")]
		public string Name { get; set; }

		[XmlElement("Key")]
		public string Key { get; set; }

		[XmlElement("Url")]
		public string Url { get; set; }

		[XmlElement("BlogGroupInfo")]
		public BlogGroupInfo BlogGroupInfo { get; set; }

		public override bool Equals(object obj) {
			Blog blog = (Blog)obj;
			return (blog.Id == Id && blog.Key==Key);
		}
		public override int GetHashCode() {
			return Id.GetHashCode() ^ Key.GetHashCode();
		}
		public override string ToString() {
			return Name;
		}

		internal static Blog Deserialize(Stream stream) {
			XmlSerializer serializer = new XmlSerializer(typeof(Blog));
			StreamReader reader = new StreamReader(stream);
			Blog blog = (Blog)serializer.Deserialize(reader);
			reader.Close();
			return blog;
		}
	}
}
